<template>
	<div id="app">
		<router-view></router-view>
	</div>
</template>

<script>
mui.init();
import {mapGetters, mapActions} from 'vuex';

export default {
	name: 'app',
	beforeCreate: function(){
		var userInfo = localStorage.getItem('userInfo');
		userInfo = userInfo? JSON.parse(userInfo): {};
		if(userInfo.nickname){ //登录过了
			require('./util/socket.js');
		}else{
			alert('11111')
			mui.openWindow({
				url: './html/login.html',
				id: 'login'
			});
		}
		
	},
	mounted: function(){
		
	},
	computed: mapGetters([
		'loadingStatus'
	]),
	//监听路由变化
	watch: {
		$route(to, from){
			// to和from 都是json对象
			var path = to.path;
			/**console.log(to.path);  to.path为将跳转的地址
			if(to.path==='/top250'){
				this.$store.dispatch('showHeader');
			}
			else this.$store.dispatch('hideHeader');
			**/
		}
	},
	data () {
		return {
			msg: 'Welcome to Your Vue.js App'
		}
	}
}
</script>

<style scoped>

</style>